<template>
	<view class="content">
		<!-- 排序、高级筛选 -->
		<!-- <view class="screen-cont">
		</view> -->
		<mescroll-uni class="my-mescroll" ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback" @up="upCallback">
		
		<!-- 客户列表 -->
		<view class="cus-list">
			<view class="item" @click="showCusDetail(item)" v-for="(item, index) in dataList">
				<view class="head">
					<text class="text">{{item.customerName}}</text>
					<view class="state-box">
						<view :class="item.isAudit==1?'state success':'state info'" >
							{{utils.getDictLabelName("customerUserAudit",item.isAudit)}}
							
						</view>
					
					</view>
				</view>
				<view class="cus-info">
					<view class="info-item">
						<text class="left">负责人：{{item.userNickName}}</text>
					</view>
					<view class="info-item flex">
						<text class="left">最后跟进时间：{{item.createTime}}</text>
						<!-- <view class="img-box">
							<image class="img" src="../../static/images/icon_money_select.png" mode=""></image>
							<image class="img" src="../../static/images/icon_star_select.png" mode=""></image>
						</view> -->
					</view>
					<!-- <view class="info-item">
						<text class="left">客户等级：</text>
					</view> -->
				</view>
			</view>
			 
		</view>
		</mescroll-uni>
	</view>
</template>

<script>
	import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js';
	import api from '@/api/api.js';
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				mescroll:undefined,
				downOption: {
					auto: false //是否在初始化后,自动执行downCallback; 默认true
				},
				upOption: {
					onScroll:true,
					use: true, // 是否启用上拉加载; 默认true
					auto: true, // 是否在初始化完毕之后自动执行上拉加载的回调; 默认true
					page: {
						num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
						size: 10 // 每页数据的数量,默认10
					},
					noMoreSize: 1, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
					empty: {
						tip: '暂无相关数据'
					}
				},
				dataList: [],
			}
		},
		onLoad() {
			// 修改顶部导航背景色
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: '#39b54a',
				animation: {
					duration: 400,
					timingFunc: 'easeIn'
				}
			})
		},
		onShow() {
			this.mescroll.resetUpScroll()
		},
		methods: {
			// mescroll组件初始化的回调,可获取到mescroll对象
			mescrollInit(mescroll) {
				this.mescroll = mescroll;
			},
			/*下拉刷新的回调 */
			downCallback(mescroll) {
				mescroll.resetUpScroll()
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				this.getAuditCustomerList(page);
			},
			getAuditCustomerList(page){
				var data = {page:page.num};
				var that=this;
				api.getAuditCustomerList(data).then(
					res => {
						if(res.code==200){
						
							//设置列表数据
							if (page.num == 1) {
								that.dataList = res.data.list; 
								
							} else {
								that.dataList = that.dataList.concat(res.data.list);
								 
							}
							that.mescroll.endBySize(res.data.list.length, res.data.total);
							
						}else{
							uni.showToast({
								icon:'none',
								title: "请求失败",
							});
							that.dataList = null;
							mescroll.endErr();
							// that.mescroll.endSuccess(0);
						}
					},
					rej => {}
				);
			},
			// 查看客户详情
			showCusDetail(item){
				uni.navigateTo({
					url: '../../customer/customDetail?customerId='+item.customerId+'&customerUserId='+item.customerUserId
				})
			}
			 
		}
	}
</script>

<style scoped lang="scss">
	.bg-green{
		background-color: #39b54a;
	}
	// 筛选
	// .screen-cont{
	// 	height: 80upx;
	// 	background: #fff;
	// 	margin-top: 100upx;
	// }
	// 客户列表
	.cus-list{
		background: #fff;
		.item{
			padding: 20upx 40upx;
			border-bottom: 1px solid #f7f7f7;
			&:last-child{
				border-bottom: none;
			}
			.head{
				display: flex;
				align-items: center;
				justify-content: space-between;
				.text{
					font-size: 32upx;
					color: #000;
				}
				.state-box{
					.state{
						width: 120upx;
						padding: 10upx 0;
						font-size: 24upx;
						text-align: center;
						&.param{
							background: #EBF3FE;
							color: #458BEB;
						}
						&.info{
							background: #F8F8F8;
							color: #BFBFBF;
						}
						&.success{
							background: #E7F7ED;
							color: #2FAC5F;
						}
					}
				}
				.btn-box{
					.deal-btn{
						text-align: center;
						width: 120upx;
						padding: 10upx 0;
						text-align: center;
						font-size: 24upx;
						border-radius: 4upx;
						&.deal{
							background: #0aAC44;
							color: #fff;
						}
						&.un-deal{
							background: #EFEFEF;
							color: #BDBDBD;
						}
					}
				}
			}
			.cus-info{
				margin-top: 20upx;
				.info-item{
					&.flex{
						display: flex;
						align-items: center;
						justify-content: space-between;
						.img-box{
							display: flex;
							align-items: center;
							.img{
								width: 40upx;
								height: 40upx;
								margin-left: 10upx;
							}
						}
					}
					.left{
						font-size: 28upx;
						color: #737373;
					}
				}
			}
		}
	}
	
</style>
